#pragma once
#ifndef TCPSOCKET_H
#define TCPSOCKET_H

#include <QObject>
#include<QTcpSocket>
#include <QHostAddress>

class TcpSocket : public QObject
{
    Q_OBJECT

public:
    TcpSocket(QTcpSocket* socket, QObject* parent=nullptr);
    void setName(const QString& name);
    void setCreateRoomId(const QString& create_room_id);
    void setJoinRoomId(const QString& join_room_id);

    int read(char* buf, int size);
    int write(const char* buf, int size);
    QHostAddress peerAddress();
    int peerPort();
    QTcpSocket* getSock();
    QString getCreateRoomId();
    QString getName();


private:
    QTcpSocket* socket;
    QString name; //用户名
    QString create_room_id; //创建的房间号
    QString join_room_id; //加入的房间号
};

#endif // TCPSOCKET_H
